package me.jiatao.wan.paging3.footer

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.paging.LoadState
import androidx.paging.LoadStateAdapter
import me.jiatao.wan.R
import me.jiatao.wan.paging3.home.HomeArticleAdapter

/**
 * @Author: JiaTao
 * @CreateDate: 2021/8/29 18:53
 * @Version: 1.0
 * @Description:
 */

class FooterAdapter(
    private val adapter: HomeArticleAdapter
) : LoadStateAdapter<FooterViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, loadState: LoadState): FooterViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.layout_footer_view_holder, parent, false)

        return FooterViewHolder(view) {
            adapter.retry()
        }
    }

    override fun onBindViewHolder(holder: FooterViewHolder, loadState: LoadState) {
        holder.bindView(loadState)
    }
}